/**
 * 
 * @author Travis C lynch <travisclynch@student.midlandstech.edu>
 * @version Apr 3 2012
 * <p>
 * <b>Instructions:</b><br>
 * Write a definition for two recursive methods.
 * <ul>
 * <li>public static String filter(String s, String rem) to return a String that is the result of removing every occurrence of all of the characters in the second parameter from the first parameter. For example, filter("abcdbdabdcbddda","bd") should return the String "acaca".
 * <li>public static String reverse(String s) to return a string which is the same characters as s, but in reverse order.
 * </ul>
 * Write a main method to input a string from the user, then input a String of characters to remove, then print out the result of calling remove with those, as well a the original string reversed, then repeat as the user wishes.
 * Hint: If s is a String, s.substring(1) is all but the first character of s
 * <p>
 * <b>Description:</b><br>
 * A class that uses generic data types
 * 
 */
import java.util.*;
public class Recursive {
	/**
	 * @param s String to be filtered
	 * @param rem Filters param for string to be filtered
	 * @return String that will not have the values of "rem" param in it
	 */
	public static String filter(String s, String rem){
		if(s.length()==0) return s;
		//Variable to hold the first Char of the string.
		char ch = s.charAt(0);
		if(rem.length()==0) return s;
		if(rem.indexOf(""+ch)==(-1)){		
			return ch + filter(s.substring(1), rem);
		}else{
			return filter(s.substring(1), rem);
		}
	}
	/**
	 * @param s String to be reversed
	 * @return a reversed version of @param s
	 */
	public static String reverse(String s){
		if(s.length()==0) return s;
		//Variable to hold the first Char of the string.
		char ch = s.charAt(0);
		return reverse(s.substring(1)) + ch;
	}
	public static void main(String[] args) {
		Scanner kbd = new Scanner(System.in);
		System.out.print("Please Enter a String of Charictors to filter and reverse: ");
		String s = kbd.nextLine();
		System.out.print("\nPlease Enter a String of Charictors to filter for: ");
		String rem = kbd.nextLine();
		System.out.println();
		System.out.println(filter(s,rem));
		System.out.println(reverse(s));
		
		
	}

}
